var Mock = require('mockjs')
// Mock.mock('http/localhost:8080/login', 'post', function(options) {
//   console.log(options)
//   return Mock.mock({
//     status: 200,
//     message: '登录成功',
//     data: { token: '@guid()', body: options.body }
//   })
// })

Mock.mock(/^http:\/\/localhost:8080\/liftNavList/, 'post', function(options) {
  // console.log(JSON.parse(options.body).params)
  const url = JSON.parse(options.body).params
  if (url === 'index') {
    return Mock.mock({
      status: 200,
      message: '登录成功',
      data: [
        {
          id: 1,
          name: '商品管理',
          children: [
            { id: 11, path: '/index', name: '系统首页' },
            { id: 12, path: '/index/setting', name: '账号设置' },
            { id: 13, path: '/index/info', name: '系统信息' },
            { id: 14, path: '/index/log', name: '登录日志' }
          ]
        }
      ]
    })
  } else if (url.slice(0, 5) === 'goods') {
    return Mock.mock({
      status: 200,
      message: '登录成功',
      data: [
        {
          id: 1,
          name: '商品管理',
          children: [
            { id: 11, path: '/goods/list', name: '商品列表' },
            { id: 12, path: '/goods/add', name: '添加商品' },
            { id: 13, path: '/goods/audit', name: '商品审核' },
            { id: 14, path: '/goods/recycle', name: '商品回收站' },
            { id: 15, path: '/goods/evaluate', name: '商品评价' }
          ]
        },
        {
          id: 2,
          name: '商品配置',
          children: [
            { id: 21, path: '/goods/classify', name: '商品分类' },
            { id: 22, path: '/goods/parameter', name: '规格参数' },
            { id: 23, path: '/goods/brand', name: '品牌管理' },
            { id: 24, path: '/goods/library', name: '图片库管理' }
          ]
        }
      ]
    })
  } else if (url.slice(0, 9) === 'operation') {
    return Mock.mock({
      status: 200,
      message: '登录成功',
      data: [
        {
          id: 1,
          name: '秒杀专区',
          children: [
            { id: 11, path: '/operation/list', name: '秒杀活动列表' },
            { id: 12, path: '/operation/time', name: '时间段列表' }
          ]
        },
        {
          id: 2,
          name: '满减专区',
          children: [
            { id: 21, path: '/operation/fullReduction', name: '满减活动列表' },
            { id: 22, path: '/operation/add', name: '添加满减活动' }
          ]
        },
        {
          id: 3,
          name: '优惠卷管理',
          children: [
            { id: 31, path: '/operation', name: '优惠卷列表' },
            { id: 32, path: '/operation', name: '添加优惠卷' },
            { id: 33, path: '/operation/setting', name: '优惠卷查询' }
          ]
        },
        {
          id: 4,
          name: '活动管理',
          children: [
            { id: 41, path: '/operation', name: '活动列表' },
            { id: 42, path: '/operation/setting', name: '添加活动' }
          ]
        },
        {
          id: 5,
          name: '广告管理',
          children: [
            { id: 51, path: '/operation/advertising', name: '广告列表' },
            { id: 52, path: '/operation/activity', name: '广告活动' }
          ]
        }
      ]
    })
  }
})
